“Peripheral storage devices” are well-known in the art of computing, in form factors such as USB flash drives (UFD); PC-cards; and small storage cards used with digital cameras, music players, handheld and palmtop computers, and cellular telephones. Peripheral storage devices also include portable magnetic disks and portable digital appliances (music players and cellular telephones) that double as general-purpose storage devices.
The process of data transfer (i.e. of one or more data objects) between the host and the peripheral storage device should not be interrupted before it is completed.
Many UFD devices provide a visual indication upon completion of any given data transfer operation. For example, certain UFD devices include a light which flashes upon completion of a given data transfer operation.
It often happens that a data transfer operation fails, for example, due to a premature disconnection of the peripheral storage device from the host device or due to a power failure or due to buffer overflow.
When such an event occurs, there is a risk of damage to locally-stored stored “storage-system data structures” residing on the “target” peripheral storage device that is targeted by the failed file transfer. Examples of such “at-risk” storage-system data structures include but are not limited to file system table(s) (for example, FAT32 tables), directory tree data structures, and flash mapping tables, each of which can reside “locally” on the “target” peripheral storage device. Unfortunately, such damage is liable to corrupt the storage device and thus render the device unusable to the average user.
FIG. 1 is a block diagram of a system in which a failure of a data transfer operation may occur. In the example of FIG. 1, host device 10 (for example, a personal computer, PDA, or cell phone) is coupled to the “target” peripheral storage device 50 (for example, a flash storage device such as a UFD or a flash memory card such as an MMC or SD card) via a communications link 15 between host-side interface 20 and device-side interface 55 (for example, respective USB or SD interfaces). Typically, the storage of a peripheral storage device is divided into two storage regions (i.e. physical or logical locations)—a user-data storage region 60 where user data (for example, one or more files or other data objects) is stored and a system data storage region 70 where system data is stored.
Typically, the storage-system data stored on the peripheral storage device 50 is organized into various data structures 75A-B (the number of which may vary from that shown in FIG. 1)—for example, file system tables such as a FAT32 tables or data structure(s) describing a directory tree or flash mapping table(s) or any other data structure. For convenience, storage system data structures 75A-B may be referred to more generally as storage system data structures 75.
In the normal course of operation, one or more of the storage system data structures 75 may be modified, for example, by the controller (not shown) of target storage device 50, whenever user data is written to or erased from target storage device 50.
As shown in FIG. 1, an attempt 5 is made to copy or move data (for example, one or more files or other data objects) from host device 10 to target peripheral storage device 50—the attempt to transfer data from host device 10 to storage device 50 is referred to as an attempted “outgoing” inter-device data transfer from host device 10 to storage device 50.
In the example of FIG. 1, the inter-device data transfer operation is managed, on the host side, by data-transfer manager 25, for example, storage-system code (e.g. of a file-oriented storage system or object oriented storage system) which, when executed (for example by microprocessor 89), is operative to effect the outgoing data transfer operation. In one particular example, data-transfer manager 25 is provided as an operating system component.
In one example, a single file is copied from the host device 10 to the storage device 50. In this case, not only is the data of the copied file written to the user data region 60, but the various data structures in the system data region 70 must be updated—for example, the directory data structure must be updated to reflect the presence of the “new” file, the FAT tables must be updated, and the flash management tables must be updated.
If the data transfer operation is unexpectedly aborted (e.g. due to a premature device detachment or power failure or buffer overflow or any other cause) when updating one or more storage system data structures 75′ there is a risk of corruption of one or more of the “partially modified” storage system data structures 75.
There are different scenarios where it is not required to re-write all system data in the system data region 70 during the data transfer operation, but rather only a particular portion of the system data. In one scenario, there are multiple copies of a particular table (for example, multiple copies of a FAT32 table—not necessarily identical) residing on the target storage device 50, and a given file transfer operation only modifies one or some of these multiple tables without modifying others. In another scenario, only a certain portion of a storage-system data structure (for example, only a portion of a file system table) is modified, while the rest of the storage-system data structure is left un-modified. In yet another scenario, multiple redundant copies (for example, including “older” versions and “newer” versions) of the same storage system table reside on the storage device 50.
In the example of FIG. 1, some storage system data structures (i.e. storage system data structure 75A) are modified by the outgoing data transfer 5, while others (i.e. storage data structure 75B) are not. This modification of a data structure is illustrated in the figure by the asterisk notation.
For the present disclosure, regions of the system data region 70 that are not modified during a given inter-device data transfer operation are referred to as “clean locations” on the storage device 50. Thus, the region where system data structure 75B resides is one example of “clean location” on the storage device 50.
It is appreciated that in some data transfer operations, some portions of a particular data structure may be modified, while other portions are left unmodified. The regions in which these “unmodified” portions reside are another example of a “clean location” on storage device 50 that is not modified by the inter-device data transfer operation.